package org.gbif.crawler.ws;

import org.gbif.ws.annotation.NullForNotFound;
import org.gbif.ws.util.ExtraMediaTypes;

import java.util.List;
import java.util.UUID;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.google.inject.Inject;


/**
 * The crawl dataset metrics web service.
 */
@Produces({MediaType.APPLICATION_JSON, ExtraMediaTypes.APPLICATION_JAVASCRIPT})
@Path("dataset/process")
@Deprecated
public class DatasetProcessResource {

  private final DatasetProcessService service;


  @Inject
  public DatasetProcessResource(DatasetProcessService service) {
    this.service = service;
  }

  @GET
  public List<DatasetProcessStatus> getAll() {
    return service.listAllDatasetProcesses();
  }

  @Path("running")
  @GET
  public List<DatasetProcessStatus> getRunning() {
    return service.listRunningDatasetProcesses();
  }

  @Path("queued")
  @GET
  public List<DatasetProcessStatus> getQueued() {
    return service.listQueuedDatasetProcesses();
  }

  @GET
  @Path("detail/{key}")
  @NullForNotFound
  public DatasetProcessStatus getDatasetMetrics(@PathParam("key") UUID key) {
    return service.getDatasetProcessStatus(key);
  }

}
